/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jdbc.dataAccess;

import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

/**
 *
 * @author Baron
 */
public class DBConnection {

      public static java.sql.Connection getConnection(ConnectionSettings connSettings) throws SQLException, ClassNotFoundException {

            java.sql.Connection conn = null;

            Properties connectionProps = new Properties();
            connectionProps.put("user", connSettings.getUser());
            connectionProps.put("password", connSettings.getPassword());

            Class.forName(connSettings.getDriver());
            conn = DriverManager.getConnection(connSettings.getUrl(),
                    connectionProps);

            System.out.println("Connected to database");
            return conn;

      }
}
